<template>
	<view class="wpprs">
		<uni-search-bar placeholder="请输入公司名称/类别/SN/品牌/仪器名称" v-model="keyword" bgColor="#fff" @confirm="getList" />
		<scroll-view class="scrollbox" scroll-y>
			<view class="list" v-for="(item, idx) in workRecordList" :key="idx" @click="toDetails(item)">
				<view class="title">
					安装时间：
					<uni-dateformat :date="item.updateTime"></uni-dateformat>
				</view>
				<view class="ctn">
					<image :src="item.skuImg"></image>
					<view class="nams">
						<view>品牌：{{ item.skuBrand }}</view>
						<view>分类：{{ item.skuCategory }}</view>
						<view>名称：{{ item.skuName }}</view>
						<view>SN：{{ item.productSerial }}</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
import { workRecord } from '../../api/order.js';
export default {
	name: 'historylist',
	data() {
		return {
			keyword: '',
			type: '',
			workRecordList: []
		};
	},
	onLoad(e) {
		this.type = e.type;
		uni.setNavigationBarTitle({
			title: `我的${e.name}记录`
		});
		this.getList();
	},
	methods: {
		toDetails(val) {
			try {
				uni.navigateTo({
					url: `/pages/orderdetails/orderdetails?orderid=${val.workOrderId}&id=${val.productId}&url=${val.skuImg}&productNames=${val.skuName}`
				});
			} catch (e) {
				uni.navigateTo({
					url: `/pages/orderdetails/orderdetails?result=${val.result}&orderid=${val.id}&id=${val.productDTOS[0].id}&url=${val.productDTOS[0].productImg}&productNames=${val.productNames}`
				});
			}
		},
		getList() {
			workRecord({
				type: this.type,
				keyword: this.keyword
			}).then((data) => {
				this.workRecordList = data.content.list;
				// console.log(data.content.list);
			});
		}
	}
};
</script>

<style scoped lang="less">
.wpprs {
	width: 100%;
	height: 100%;
	position: fixed;
	left: 0;
	top: 0;
	background-repeat: no-repeat;
	background-size: 100%;
	box-sizing: border-box;
	background-color: #f1f1f1;
}

.scrollbox {
	height: calc(100% - 160upx);
	padding: 20upx;
	box-sizing: border-box;
	.list {
		background-color: #fff;
		border-radius: 10upx;
		padding: 0 20upx;
		margin-bottom: 30upx;
		.title {
			padding: 20upx 0;
			border-bottom: 1px #ccc solid;
		}
		.ctn {
			display: flex;
			padding: 20upx 0;
			image {
				width: 200upx;
				height: 200upx;
			}
			.nams {
				padding-left: 20upx;
				view {
					padding: 10upx;
				}
			}
		}
	}
}
</style>
